package com.tiny.model;

import java.util.List;

import com.jfinal.plugin.activerecord.Model;

public class User extends Model<User> {

	private static final long serialVersionUID = 5721481570867001057L;

	public static final User dao = new User();

	public long getId() {
		return this.getInt("id");
	}

	public User findByUsername(String userName) {
		User user = dao.findFirst(" select * from user where username =? ",
				userName);
		return user;
	}

	public List<Role> getRoles() {
		return Role.dao
				.find(" select r.* from role r,userrole ur where ur.role_id=r.id and ur.user_id =? ",
						this.getId());
	}
}
